#打开f.txt文件，使用两种不同的编码方式打开，分别是utf-8和gbk，打印报错信息，进行比较
try:
    with open('f.txt','r',encoding='utf-8') as f:
        print(f.read())
    try:
        with open('f.txt','r',encoding='gbk') as f:
            print(f.read())
    except Exception as e:
        print(e)
except Exception as e:
    print(e)